
app.controller('productListPageCtrl', function ($scope, $location,$http){
    $scope.showCartCount=function(){
        var shoppingCart =new ShoppingCart();
        var cartCount=shoppingCart.computeSumCount();
        $scope.cartCount = cartCount||0;
        if(cartCount==0){
            $location.path("/productListPage");
        }
    }
    $http.get("../json/productList.json").success(
        function(response){
            $scope.productList=response;
        }
    );
    $scope.jumphomePage=function(){
        $location.path("/")
    };
    $scope.jumpShoppingCartPage= function(){
        $location.path("/shoppingCartPage")
    };
    $scope.addButtonEvent=function(product,num){
        var control=new Control();
        var cartList=control.changeCartListInfo(product,num);
        control.saveGoodsInfo(cartList);
        $scope.showCartCount();
    }
});
